define(["router", "framework/commonService",
        'framework/topNavCtrl',
        'framework/login',
        'business/user/router/userRouter',
        'business/common/router/leftMenuRouter',
        'business/blog/router/blogRouter', 'business/interview/router/interviewRouter'],
    function (router, service, topNavCtrl, login, userRouter, leftMenuRouter, blogRouter, interviewRouter) {

        var dependency = ['ui.router', service.name, login.name, topNavCtrl.name, userRouter.name, leftMenuRouter.name, blogRouter.name, interviewRouter.name];
        var framework = angular.module("framework", dependency);
        framework.directive("tiModal", function () {
            return {
                restrict: "A",//E 作为元素名使用 A 作为属性使用C 作为类名使用M 作为注释使用restrict 默认值为 EA, 即可以通过元素名和属性名来调用指令。
                templateUrl: 'app/business/common/view/alert.html',
                scope: {
                    id: '@id',
                    age: '=',
                    changeAge: '&changeMyAge'
                },
                controller: function ($scope) {
                    $scope.id = 'leifeng';
                    $scope.say = function (someDirective) {
                        console.log('Got:' + someDirective);
                    };
                }
            }
        });


        framework.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
            $urlRouterProvider.otherwise('#/login')
        }])

        framework.run(function ($rootScope, COOKIES, $state) {
            $rootScope.$on("$stateChangeStart", function (event, toState, toParams, fromState, fromParams) {
                if (toState.name.indexOf("login") != -1) {

                } else if (!COOKIES.getCookie("UserName")) {
                    window.location.href = "#/login";
                    $rootScope.isLoginPage = true;
                    return;
                }
            })
        })

        return framework;
    })